<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>crm</title>
	<link rel="stylesheet" type="text/css" href="../css/style.css">
	<link rel="stylesheet" type="text/css" href="../js/layer/theme/default/layer.css">
	<script type="text/javascript" src="../js/vue.js"></script>
	<script type="text/javascript" src="../js/filter.js"></script>
	<link href="../images/favicon.ico" rel="icon" type="image/x-icon" />
	<!-- <script src="https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js"></script> -->
	<script type="text/javascript" src="../js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="../js/jquery.serializejson.js"></script>
	<script type="text/javascript" src="../js/config.js"></script>
	<script type="text/javascript" src="../js/layer/layer.js"></script>
	<script type="text/javascript" src="../js/paging.js"></script>
	
</head>
<body>
	<div class="header">
		<img src="../images/logo.png">
		<p>欢迎您，<span id="userName">123</span><a onclick="logout()">退出登录</a></p>
	</div>
	<div class="crm-content" id="crmList">
		<a onclick="newBuyCar()" v-if="resourceList.indexOf('新增买车意向') != -1" class="add-button">新增买车意向</a>
		<a onclick="newSellCar()" v-if="resourceList.indexOf('新增卖车意向') != -1"  class="add-button">新增卖车意向</a>
		<a onclick="batchDistributionAll()" v-if="resourceList.indexOf('批量分配') != -1"  class="add-button">批量分配</a>
		<a href="sysParamConf.html" v-if="resourceList.indexOf('参数配置') != -1"  class="add-button">参数配置</a>
		
		
		
		<!-- <a onclick="followUp()" class="add-button">跟进</a> -->
		
		<table class="list-box">
			<tr>
				<th width="50"><input type="checkbox" id="checkAll"></th>
				<th>客户名称</th>
				<th>意向状态</th>
				<th width="320">基本信息</th>
				<th>备注</th>
				<th>到店</th>
				<th>跟进历史</th>
				<th width="200">操作</th>
			</tr>
			<tr v-for="(re,index) in res">
				<td><input type="checkbox" class="checkList" v-bind:data-intentionId="re.intentionId" ></td>
				<td>{{re.customer.customerName}}</td>
				<td>{{re.intentionState | filterIntentionState}}</td>
				<td>
					<div class="detial-left">
						<p>电话：{{re.customer.customerPhone}}</p>
						<p v-if="re.intentionType == '00'">求购：{{re.modelName}}</span></p>
						<p v-if="re.intentionType == '01'">出售：{{re.modelName}}</span></p>
						<p v-if="re.intentionType == '00'">预算：{{re.intentionBudgetMin}}万 - {{re.intentionBudgetMax}}万</p>
						<p v-if="re.intentionType == '01'">期望价格：{{re.expectedPriceMin}}万 - {{re.expectedPriceMax}}万</p>
						<p>客户来源：{{re.customer.channel.channelName}}</p>
						
					</div>
					<div class="detial-left">
						<p>客户级别：{{re.customer.customerLevel.levelTxt}}</p>
						<p>负责人：{{re.rechargerName}}</p>
						<p>归属地区：{{re.customer.provinceName}}{{re.customer.cityName}}</p>
						<p>创建时间：{{re.createTime | filterGetDate}}</p>
						<p>预约时间：{{re.appointmentTime | filterGetDate}}</p>
					</div>
				</td>
				<td>{{re.intentionRemark}}</td>
				<td>{{re.reachCount}}</td>
				<td>
					<p>最后操作：{{re.lastFollowTimeDesc}}</p>
					<p>跟进人：{{re.lastFollower}}</p>
					<p>{{re.lastFollowResult | lastlastFollowResult }}</p>
					<p><span v-bind:data-intentionId="re.intentionId" onclick="moreHistory(this)" id="more">更多</span></p>
				</td>
				<td>
					<span class="over-small" v-if="re.intentionState == '01' && resourceList.indexOf('批量分配') != -1" v-bind:data-intentionId="re.intentionId" onclick="batchDistribution(this)">分配</span>
					<span class="over-small" v-if="re.intentionState != '01' && resourceList.indexOf('客户跟进') != -1 && re.intentionState != '30'" v-bind:data-intentionId="re.intentionId" onclick="followUp(this)">跟进</span>
					<span class="over-small" v-bind:data-intentionId="re.intentionId" onclick="editBuyCar(this)" v-if="re.intentionType == '00'">编辑</span>
					<span class="over-small" v-bind:data-intentionId="re.intentionId" onclick="editSellCar(this)" v-if="re.intentionType == '01'">编辑</span>
				</td>
			</tr>
		</table>
		<div id="page" class="page_div"></div>
	





















<!-- 新增买车意向弹窗  -->
	<form class="cell-content" id="addBuyForm" style="display: none;" onsubmit="return sendNewBuyCar()">
		<div class="cell">
			<label><span class="red">*</span>客户姓名</label>
			<input type="text" name="customer[customerName]" id="customer[customerName]"  required>
			<div class="group-radio"><input name="customer[customerGender]" type="radio" value="0" checked="checked" />男</div> 
			<div class="group-radio"><input name="customer[customerGender]" type="radio" value="1"  />女</div> 
		</div>
		<div class="cell">
			<label><span class="red">*</span>联系电话</label>
			<input type="tel" name="customer[customerPhone]" required maxlength="11" onchange="checkPhone(this)">
			<label><span class="red">*</span>客户来源</label>
			<select name="customer[channelId]" required>
				<option value="">请选择</option>
				<option v-for="channel in channelList" v-bind:value="channel.channelId">{{channel.channelName}}</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>归属地区</label>
			<select name="customer[provinceId]" onchange="setCitys(this.value)" required>
				<option value="">请选择</option>
				<option v-for="province in provinces" v-bind:value="province.provinceId">{{province.provinceName}}</option>
			</select>
			<select name="customer[cityId]" required>
				<option value="">请选择</option>
				<option v-for="city in citys">{{city.cityName}}</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>预算</label>
			<div class="group-input"><input type="number" name="intentionBudgetMin" required><span>万元</span></div>
			<div class="group-input"><input type="number" name="intentionBudgetMax" required><span>万元</span></div>
		</div>
		<div class="carsBox">
			<div class="cell carsList">
				<label>品牌／车系</label>
				<select name="brandId" onchange="setSeries(this)">
					<option value="">请选择</option>
					<option v-for="brand in brands" v-bind:value="brand.brandId">{{brand.brandName}}</option>
				</select>
				<select name="seriesId" class="carsSeries" onchange="getCarInfo(this)">
					<option value="">请选择</option>
				</select>

				<span onclick="deleteCar(this)" class="delete-car">删除</span>
				<!--<div><table class="list-box"></table></div>-->
				<span onclick="alertCarList(this,0)" class="select-car" data-carIds="">车辆选择</span>
				<div class="hiddenInput"></div>
			</div>
		</div>
		
		<div class="cell">
			<button type="button" onclick="addCarsList(this)" style="margin-left: 106px;">添加意向车型</button>
		</div>
		<div class="cell">
			<label style="float: left;">备注</label>
			<textarea style="margin-left: 5px;" name="intentionRemark"></textarea>
		</div>
	</form>


<!-- 修改买车意向弹窗  -->
	<form class="cell-content" id="editBuyForm" style="display: none;">
		<input type="hidden" name="intentionId" v-bind:value="editBuyCarJson.intentionId">
		<input type="hidden" name="customerId" v-bind:value="editBuyCarJson.customerId">
		<input type="hidden" name="customer[customerId]" v-bind:value="editBuyCarJson.customer.customerId">
		<div class="cell">
			<label><span class="red">*</span>客户姓名</label>
			<input type="text" name="customer[customerName]" v-model="editBuyCarJson.customer.customerName" required>
			<div class="group-radio"><input name="customer[customerGender]" v-model="editBuyCarJson.customer.customerGender" type="radio" value="0" checked="checked" />男</div> 
			<div class="group-radio"><input name="customer[customerGender]" v-model="editBuyCarJson.customer.customerGender" type="radio" value="1"  />女</div>
		</div>
		<div class="cell">
			<label><span class="red">*</span>联系电话</label>
			<input type="text" name="customer[customerPhone]" v-model="editBuyCarJson.customer.customerPhone"  onchange="checkPhone(this)"  required>
			<label><span class="red">*</span>客户来源</label>
			<select name="customer[channelId]" v-model="editBuyCarJson.customer.channelId" required>
				<option value="">请选择</option>
				<option v-for="channel in channelList" v-bind:value="channel.channelId">{{channel.channelName}}</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>归属地区</label>
			<select name="customer[provinceId]" onchange="setCitys(this.value)" v-model="editBuyCarJson.customer.provinceId" required>
				<option value="">请选择</option>
				<option v-for="province in provinces" v-bind:value="province.provinceId">{{province.provinceName}}</option>
			</select>
			<select name="customer[cityId]" v-model="editBuyCarJson.customer.cityId" required>
				<option value="">请选择</option>
				<option v-for="city in citys" v-bind:value="city.cityId">{{city.cityName}}</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>预算</label>
			<div class="group-input"><input type="number" name="intentionBudgetMin" v-model="editBuyCarJson.intentionBudgetMin" required><span>万元</span></div>
			<div class="group-input"><input type="number" name="intentionBudgetMax" v-model="editBuyCarJson.intentionBudgetMax" required><span>万元</span></div>
		</div>
		<div class="carsBox">
			<div class="cell carsList" v-for="cars in editBuyCarJson.intentionModelList">
				<label>品牌／车系</label>
				<select name="brandId" class="carsBrand" v-model="cars.brandId" onchange="setSeries(this)" >
					<option value="">请选择</option>
					<option v-for="brand in brands" v-bind:value="brand.brandId">{{brand.brandName}}</option>
				</select>
				<select name="seriesId" v-model="cars.seriesId" class="carsSeries" >
					<option value="">请选择</option>
				</select>
				<span onclick="deleteCar(this)"  class="delete-car">删除</span>
				<span onclick="alertCarList(this,1)" class="select-car" :data-carIds="cars.carIds"  :data-seriesId="cars.seriesId" :data-brandId="cars.brandId">车辆选择</span>
				<div class="hiddenInput">
					<div v-for="carId  in cars.carIds">
						<input type="hidden" v-bind:value="carId" name="intentionModelList[][carId]">
						<input type="hidden" v-bind:value="cars.seriesId" name="intentionModelList[][seriesId]">
						<input type="hidden" v-bind:value="cars.brandId" name="intentionModelList[][brandId]">
					</div>
				</div>
			</div>
		</div>
		
		<div class="cell">
			<button type="button" onclick="addCarsList(this)" style="margin-left: 106px;">添加意向车型</button>
		</div>
		<div class="cell">
			<label style="float: left;">备注</label>
			<textarea style="margin-left: 5px;" name="intentionRemark" v-model="editBuyCarJson.intentionRemark"></textarea>
		</div>
	</form>



<!-- 新增卖车意向弹窗  -->
	<form class="cell-content" id="addSellForm" style="display: none;">
		<div class="cell">
			<label><span class="red">*</span>客户姓名</label>
			<input type="text" name="customer[customerName]" required>
			<div class="group-radio"><input name="customer[customerGender]" type="radio" value="0"  checked="checked" />男</div> 
			<div class="group-radio"><input name="customer[customerGender]" type="radio" value="1"  />女</div> 
		</div>
		<div class="cell">
			<label><span class="red">*</span>联系电话</label>
			<input type="text" name="customer[customerPhone]"  onchange="checkPhone(this)" required>
			<label>客户来源</label>
			<select name="customer[channelId]"  required>
				<option value="">请选择</option>
				<option v-for="channel in channelList" v-bind:value="channel.channelId">{{channel.channelName}}</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>归属地区</label>
			<select name="customer[provinceId]" onchange="setCitys(this.value)" required>
				<option value="">请选择</option>
				<option v-for="province in provinces" v-bind:value="province.provinceId">{{province.provinceName}}</option>
			</select>
			<select name="customer[cityId]" required>
				<option value="">请选择</option>
				<option v-for="city in citys">{{city.cityName}}</option>
			</select>
		</div>
		<div class="cell carsList">
			<label><span class="red">*</span>品牌／车系</label>
			<select name="intentionModelList[][brandId]" onchange="setSeries(this)" required>
				<option value="">请选择</option>
				<option v-for="brand in brands" v-bind:value="brand.brandId">{{brand.brandName}}</option>
			</select>
			<select name="intentionModelList[][seriesId]" class="carsSeries" required>
				<option value="">请选择</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>里程</label>
			<div class="group-input"><input type="number" name="carMileage"  required><span>万公里</span></div>
			<label><span class="red">*</span>外观颜色</label>
			<input type="text" name="carColor" required>
		</div>
		<div class="cell">
			<label><span class="red">*</span>期望价格</label>
			<div class="group-input"><input type="number" name="expectedPriceMin"  required><span>万元</span></div>
			<div class="group-input"><input type="number" name="expectedPriceMax"  required><span>万元</span></div>
		</div>
		<div class="cell">
			<label>上牌年月</label>
			<input type="month" name="licenseDate">
		</div>
		<div class="cell">
			<label style="float: left;">备注</label>
			<textarea style="margin-left: 5px;" name="intentionRemark"></textarea>
		</div>
	</form>

<!-- 修改卖车意向 -->
	<form class="cell-content" id="editSellForm" style="display: none;">
		<input type="hidden" name="intentionId" v-model="editSellCarJson.intentionId">
		<input type="hidden" name="customerId" v-bind:value="editSellCarJson.customerId">
		<div class="cell">
			<label><span class="red">*</span>客户姓名</label>
			<input type="text" name="customer[customerName]" v-model="editSellCarJson.customer.customerName" required>
			<div class="group-radio"><input name="customer[customerGender]" v-model="editSellCarJson.customer.customerGender" type="radio" value="0" />男</div> 
			<div class="group-radio"><input name="customer[customerGender]" v-model="editSellCarJson.customer.customerGender" type="radio" value="1"  />女</div> 
		</div>
		<div class="cell">
			<label><span class="red">*</span>联系电话</label>
			<input type="text" name="customer[customerPhone]" v-model="editSellCarJson.customer.customerPhone" onchange="checkPhone(this)" required>
			<label><span class="red">*</span>客户来源</label>
			<select name="customer[channelId]" v-model="editSellCarJson.customer.channelId"  required>
				<option value="">请选择</option>
				<option v-for="channel in channelList" v-bind:value="channel.channelId">{{channel.channelName}}</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>归属地区</label>
			<select name="customer[provinceId]" onchange="setCitys(this.value)" v-model="editSellCarJson.customer.provinceId"  required>
				<option value="">请选择</option>
				<option v-for="province in provinces" v-bind:value="province.provinceId">{{province.provinceName}}</option>
			</select>
			<select name="customer[cityId]" v-model="editSellCarJson.customer.cityId"  required>
				<option value="">请选择</option>
				<option v-for="city in citys">{{city.cityName}}</option>
			</select>
		</div>
		<div class="cell carsList" v-for="cars in editBuyCarJson.intentionModelList">
			<label><span class="red">*</span>品牌／车系</label>
			<select name="intentionModelList[][brandId]" v-model="cars.brandId" onchange="setSeries(this)"  required>
				<option value="">请选择</option>
				<option v-for="brand in brands" v-bind:value="brand.brandId">{{brand.brandName}}</option>
			</select>
			<select name="intentionModelList[][seriesId]" v-model="cars.seriesId" class="carsSeries"  required>
				<option value="">请选择</option>
			</select>
		</div>
		<div class="cell">
			<label><span class="red">*</span>里程</label>
			<div class="group-input"><input type="number" name="carMileage" v-model="editSellCarJson.carMileage"  required><span>万公里</span></div>
			<label><span class="red">*</span>外观颜色</label>
			<input type="text" name="carColor"  v-model="editSellCarJson.carColor"  required>
		</div>
		<div class="cell">
			<label><span class="red">*</span>期望价格</label>
			<div class="group-input"><input type="number" name="expectedPriceMin" v-model="editSellCarJson.expectedPriceMin"  required><span>万元</span></div>
			<div class="group-input"><input type="number" name="expectedPriceMax" v-model="editSellCarJson.expectedPriceMax"  required><span>万元</span></div>
		</div>
		<div class="cell">
			<label>上牌年月</label>
			<input type="month" name="licenseDate" v-model="editSellCarJson.licenseDate">
		</div>
		<div class="cell">
			<label style="float: left;">备注</label>
			<textarea style="margin-left: 5px;" name="intentionRemark" v-model="editSellCarJson.intentionRemark"></textarea>
		</div>
	</form>


<!-- 分配意向 -->
	<form class="cell-content" id="distributionForm" style="display: none;">
		<div class="cell">
			<label style="width: 200px;">将这<span id="intentionNum"></span>条意向分配给</label>
			<select name="userId">
				<option value="">请选择</option>
				<option v-for="user in userList" v-bind:value="user.userId">{{user.userName}}</option>
			</select>
		</div>
		<div class="cell">
			<label style="width: 200px;">下次跟进</label>
			<input type="Date" name="nextFollowDatetime">
		</div>
	</form>


<!-- 跟进意向 -->
	<form class="cell-content" id="followForm" style="display: none;width: 840px;">
		<div class="cell">
			<label >跟进结果</label>
			<select name="followResult" v-model="folow.followResult">
				<option value="">请选择</option>
				<option value="01">继续跟进</option>
				<option value="02">预约看车</option>
				<option value="03">已战败</option>
				<option value="04">已失效</option>
				<option value="05">已成交</option>
			</select>
			<span v-if="folow.followResult == '01' || folow.followResult == '02' || folow.followResult == '03'">
				<label>客户级别</label>
				<select name="customerLevel">
					<option value="">请选择</option>
					<option v-for="customerLeve in customerLeveList" v-bind:value="customerLeve.levelId">{{customerLeve.levelTxt}}</option>
				</select>
			</span>
		</div>
		<div class="cell" v-if="folow.followResult == '01'">
			<label>下次跟进</label>
			<input type="date" name="nextFollowTime">
		</div>
		<div class="cell" v-if="folow.followResult == '02'">
			<label>预约时间</label>
			<input type="date" name="appointmentTime">
		</div>
		<div class="cell" v-if="folow.followResult == '03'">
			<label>战败日期</label>
			<input type="date" name="loseEfficacyTime">
		</div>
		<div class="cell" v-if="folow.followResult == '04'">
			<label>失效日期</label>
			<input type="date" name="loseEfficacyTime">
		</div>
<!-- 		<div class="cell" v-if="folow.followResult == '05'">
			<label>成交日期</label>
			<input type="date" name="FixtureTime">
		</div> -->
		<div class="cell" v-if="folow.followResult == '01' || folow.followResult == '02'">
			<label>是否到店</label>
			<div class="group-radio"><input name="isReach" type="radio" value="1" v-model="res.isReach" />是</div> 
			<div class="group-radio"><input name="isReach" type="radio" value="0" v-model="res.isReach" />否</div> 
		</div>
		<div v-if="folow.followResult == '05'">
	<!-- 		<div class="cell">
				<label>是否手动输入车辆</label>
				<div class="group-radio"><input name="autoInput" type="radio" value="1" v-model="folow.autoInput" />是</div> 
				<div class="group-radio"><input name="autoInput" type="radio" value="0" v-model="folow.autoInput" />否</div> 
			</div> -->
			<!-- <div class="cell" v-if="folow.autoInput == 1"> -->
			<div class="cell">
				<label>成交车辆</label>
				<input type="text" name="fixtureCar" >
			</div>
	<!-- 		<div class="cell" v-if=""></div>
			<div class="" v-if="folow.autoInput == 0">
				<button type="button" style="margin-left: 106px;margin-bottom: 0;" onclick="alertCarList()">选择成交车辆</button>
			</div> -->
			<div class="cell">
				<label>定金</label>
				<div class="group-input"><input type="text" name="earnest" required><span>万元</span></div>
			</div>
			<div class="cell">
				<label>成交价格</label>
				<div class="group-input"><input type="text" name="fixturePrice" required><span>万元</span></div>
			</div>
		</div>	
		<div class="cell">
			<label style="float: left;">跟进说明</label>
			<textarea name="followRemark" style="margin-left: 4px;"></textarea>
		</div>
	</form>

<!-- 车辆选择 -->
	<form id="carListForm" style="display: none;">
		<table class="list-box">
			<tr>
				<th></th>
				<th>序号</th>
				<th>车辆图片</th>
				<th>车辆标题</th>
				<th>车辆价格</th>
			</tr>
			<tr v-for="(car,index) in carList">
				<td><input type="checkbox" class="car-list-check" style="width: auto;height: auto;margin: auto;" v-bind:id="car.carId"  v-bind:value="car.carId" name="carIds[]"></td>
				<td>{{index+1}}</td>
				<td><img v-bind:src="imgUrl+car.carImage.imageUrl+'.r_150xh_90'" style="display: block;vertical-align: middle;"></td>
				<!-- <td>titile</td> -->
				<td>{{car.carTitle}}</td>
				<td>{{car.carShowPrice}}</td>
			</tr>
		</table>
	</form>

<!-- 跟进历史 -->
	<form id="historyFrom" style="display: none;">
		<table class="list-box">
			<tr>
				<th>序号</th>
				<th>跟进人</th>
				<th>跟进结果</th>
				<th>跟进说明</th>
				<th>是否到店</th>
				<th>跟进时间</th>
			</tr>
			<tr v-for="(follow,index) in followList">
				<td>{{index+1}}</td>
				<td>{{follow.followName}}</td>
				<td>{{follow.followResult}}</td>
				<td>{{follow.followRemark}}</td>
				<td>{{follow.isReach | filterIsReach}}</td>
				<td>{{follow.createTime}}</td>
			</tr>
		</table>
	</form>


	</div>
	<script type="text/javascript">
		var crmList = new Vue({
			el:'#crmList',
			data: {
				res:[],
				provinces:[],
				citys:[],
				brands:[],
				series:[],
				channelList:[],
				userList:[],
				customerLeveList:[],
				imgUrl:'',
				folow:{
					followResult:'',
					autoInput:0,

				},
				editBuyCarJson:{
					customer:{},
					intentionModelList:[]

				},
				editSellCarJson:{
					customer:{},
					intentionModelList:[]

				},
				resourceList:[],
				followList:[],
				carList:[],
			},

			methods: {
			 
			},
		})
	</script>
	<script type="text/javascript" src="../js/index.js"></script>
</body>
</html>